package com.service.impl;

import com.entity.MaterialType;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mapper.MaterialTypeMapper;
import com.service.MaterialTypeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.utils.PageObject;
import com.vo.EmployeeVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author aiou
 * @since 2025-06-12
 */
@Service
public class MaterialTypeServiceImpl implements MaterialTypeService {

    @Autowired
    private MaterialTypeMapper materialTypeMapper;

    @Override
    public PageObject<MaterialType> list(PageObject pageObject) {
        //开始分页
        PageHelper.startPage(pageObject.getCurrent(),pageObject.getSize());
        //查询数据
        List<MaterialType> list = materialTypeMapper.list();
        //PageHelper包装数据
        PageInfo<MaterialType> pageInfo = new PageInfo<>(list);
        //将数据封装进PageResult
        PageObject<MaterialType> MaterialTypePageResult
                = new PageObject<>(pageInfo.getPageNum(), pageInfo.getPageSize(), pageInfo.getTotal(), pageInfo.getList());
        return MaterialTypePageResult;
    }

    //物料类别：根据物料编码获取物料类型
    @Override
    public MaterialType getOne(String materialTypeCode) {
        return materialTypeMapper.getone(materialTypeCode);
    }

    //物料类别：新增/修改物料
    @Override
    public boolean save(MaterialType materialType) {
        return materialTypeMapper.save(materialType);
    }
    //物料类别：新增/修改物料
    @Override
    public boolean updateById(MaterialType materialType) {
        return materialTypeMapper.update(materialType);
    }

    //物料类别：删除物料
    @Override
    public boolean removeById(Integer id) {
        return materialTypeMapper.deleteById(id);
    }

    //物料类别：查询所有
    @Override
    public List<MaterialType> list() {
        return materialTypeMapper.list();
    }
}
